<template>
	<view>
		<topbar title="收益" jt_c="2" background="background:#222222;color:#fff;"></topbar>
		<view class="content">
			<view class="top_rl dis_f_sb_c" @click="show = true">
				<view>{{time_str}}</view>
				<u-icon name="calendar"></u-icon>
			</view>
			
			<view class="ban_xin">
				<view class="dis_f_co">
					<view class="bottom" v-for="(item,index) in lists">
						<view style="margin-bottom: 12rpx;" class="dis_f_sb_c">
							<view>{{item.title}}</view>
							<view style="color: #FA3534;font-size: 22rpx;font-weight: bold;">+ {{item.money}}</view>
						</view>
						<view style="color: #BBBBBB;font-size: 22rpx;line-height: 32rpx;width: 100%;" class="dis_f_sb_c">
							<view>{{item.remark}}</view>
							<view>{{item.create_time}}</view>
						</view>
					</view>
					<view style="padding-bottom: 100rpx;">
						<u-loadmore :status="status"/>
					</view>
				</view>
			</view>
			<u-calendar v-model="show" :mode="mode" @change="change"></u-calendar>
			
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				status:'loadmore',
				show: false,
				mode: 'range',
				time_str:'查看其它时间的收益',
				time:'',
				lists:[],
				type:1
			};
		},
		onLoad(opt) {
			this.type = opt.type;
			if(opt.type ==1){
				
			}
			if(opt.type == 2){
				
			}
		},
		onShow(){
			this.page = 1;
			this.lists = [];
			this.get_list();
		},
		methods:{
			change(e) {
				this.page = 1;
				this.lists = [];
				console.log(e);
				this.time_str = e.startDate + '~' + e.endDate
				this.time = e.startDate + '~' + e.endDate
				this.get_list();
			},
			get_list () {
				this.$.ajax(1, 'post', 'task/shouyi_list', {
					uid:uni.getStorageSync('uid'),
					token:uni.getStorageSync('token'),
					page:this.page,
					type:this.type,
					time:this.time
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						this.zys = res.pagecount
						if (this.type == 2) {
							this.time_str = res.time;
						}
						if(res.data != ''){
							res.data.forEach((item,index)=>{
								this.lists.push(item);
							})
						}else{
							this.status = 'nomore';
							return;
						}
						// this.lists = res.data;
					}else{
						this.password = '';
						this.$.ti_shi(res.msg);
						if(res.code == 9) {
							var that = this;
							setTimeout(function() {
								that.$.open('/pages/login/login');
							}, 2000);
						}  
					}
				})
			}
		},
		onReachBottom() {
			if(this.page+1 <= this.zys){
				this.status = 'loading';
				this.page = ++this.page;
				this.get_list();
			}else{
				this.status = 'nomore';
				return;
			}
		}
	}
</script>

<style lang="scss">
	.content{
		width: 100%;
		padding-top: calc(var(--status-bar-height) + 88rpx);
		.top_rl{
			width: 100%;
			height: 88rpx;
			background-color: #FFF;
			padding: 0 24rpx;
		}
		.ban_xin{
			width: 100%;
			padding:  24rpx;
			.bottom{
				width: 100%;
				padding: 36rpx 24rpx;
				background-color: #fff;
				box-shadow: 0rpx 6rpx 24rpx rgba(34, 34, 34, 0.05);
				border-radius: 20rpx;
				margin-bottom: 12rpx;
			}
		}
	}
</style>
